#include "cuda_util.h"
#include "cush_alloc.h"

#include <cuda.h>
#include <stdio.h>

void cush_memCheck(cush_dbuff_t* dps){
	int i = 0;
	for(i = 0; i < dps->ndevices; i++){
		fprintf(stdout, "Memcheck device %d\n", i);
		cudaSetDevice(i);
		memCheck();
	}
}

void cush_print_dbuff(cush_dbuff_t* dps){

	size_t size = dps->ndevices;
	printf("ndev =  %lu\n", size);

	switch(dps->type){
	case INT:
		printf("type = int\n");
		break;
	case FLOAT:
		printf("type = float\n");
		break;
	case DOUBLE:
		printf("type = double\n");
		break;
	default:
		printf("type = unknown\n");
		break;
	}
	
	int i = 0;
	printf("id = [ ");
	for(i = 0; i < size; i++){
		printf("%d ", dps->id[i]);
	}
	printf("]\n");

	printf("size = [ ");
	for(i = 0; i < size; i++){
		printf("%lu ", dps->size[i]);
	}
	printf("]\n");

	printf("offset = [ ");
	for(i = 0; i < size; i++){
		printf("%lu ", dps->offset[i]);
	}
	printf("]\n");

	printf("ptr = [ ");
	for(i = 0; i < size; i++){
		printf("%lu ", dps->ptr[i]);
	}
	printf("]\n");
}

/* vim: set sw=4 sts=4 et foldmethod=syntax syntax=c : */
